package com.ys.erp.entity.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ys.erp.entity.data.bean.UserPulse;
import com.ys.erp.entity.mapper.UserPulseMapper;
import com.ys.erp.entity.service.IUserPulseService;
import org.springframework.stereotype.Service;

import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
 * @author lwj
 * @date 2025/5/22
 */
    
@Service
public class IUserPulseServiceImpl extends ServiceImpl<UserPulseMapper, UserPulse> implements IUserPulseService {

    @Override
    public UserPulse getByUserId(Long userId) {
        QueryWrapper<UserPulse> qw = new QueryWrapper<>();
        qw.lambda().eq(UserPulse::getUserId, userId);
        return this.getOne(qw);
    }

    @Override
    public List<UserPulse> listByUserIds(Collection<Long> userIds) {
        QueryWrapper<UserPulse> qw = new QueryWrapper<>();
        qw.lambda().in(UserPulse::getUserId, userIds);
        return this.list(qw);
    }

    @Override
    public Map<Long, UserPulse> mapByUserIds(Collection<Long> userIds) {
        return listByUserIds(userIds).stream().collect(
                Collectors.toMap(UserPulse::getUserId, it -> it)
        );
    }

}
